import requests

class TestLogin:
    def setup(self):
        self.url="http://ihrm-test.itheima.net/api/sys/login"

    def teardown(self):
        pass
    # 登录成功
    def test01_login_success(self):
        response = requests.post(url=self.url ,json={"mobile":"13800000002","password":"123456"})
        print(response.json())

        assert response.status_code ==200
        assert response.json().get("success") is True
        assert response.json().get("code")==10000
        assert "成功" in response.text

    def test01_mobile_erorr(self):
        response = requests.post(url=self.url ,json={"mobile":"","password":"123456"})
        print(response.json())

        assert response.status_code ==200
        assert response.json().get("success") is False
        assert response.json().get("code")==20001
        assert "错误" in response.text

    def test01_password_erorr(self):
        response = requests.post(url=self.url ,json={"mobile":"13800000002","password":"123457"})
        print(response.json())

        assert response.status_code ==200
        assert response.json().get("success") is False
        assert response.json().get("code")==20001
        assert "错误" in response.text